<template>
    <div id="weltop" v-show="isLogin[userId]">
        <router-link v-for="val in weltop" :to='val.path' :id="val.id" :class="active==val.id?'on':''" :key="val.id">{{val.text}}</router-link>
        <div id="greenLine" :class="active"></div>
    </div>
</template>

<script>
export default {
    data(){
        return {
            weltop:[]
        }
    },
    props:['active'],
    created(){
        this.getWeltop();
    },
    computed:{
        userId(){
            for(let key in this.isLogin){
                if(this.isLogin[key]){
                    return key;
                }
            }
        }
    },
    methods:{
        getWeltop(){
        this.axios.get('/weltop').then((ret)=>{
          let {data,error}=ret.data;
          this.weltop=data;
        }).catch(()=>{})
      }
    }
}
</script>

<style scoped lang='scss'>
#weltop{
    width:750px;
    height:117px;
    position:fixed;
    top:0;
    background-color:#fff;
    display:flex;
    z-index: 200;
    a{
        background-color:#fff;
        text-decoration: none;
        color:#555;
        display:block;
        font-size:37px;
        line-height: 46px;
        height:46px;
        text-align: center;
        position: relative;
        margin: 35px 30px;
        z-index: 101;
    }
    .on{
        color: #39ac69;
    }
    #greenLine{
        height:7px;
        width: 46px;
        background-color: #47b34f;
        position: absolute;
        border-radius: 11px;
        bottom: 16px;
        margin-left: -23px;
    }
    #greenLine.attentionTab{
        left: 70px;
    }
    #greenLine.recipeTab{
        left: 205px;
    }
    #greenLine.recommendTab{
        left: 335px;
    }
    #greenLine.fashionTab{
        left: 510px;
    }
    #greenLine.lifeTab{
        left: 680px;
    }
}
</style>

